package com.sanjishu.enterlab.electricity.sale.service;

import com.sanjishu.enterlab.electricity.sale.domain.VerifyCode;
import com.sanjishu.enterlab.electricity.sale.mapper.VerifyCodeMapper;
import com.sanjishu.enterlab.electricity.sale.utils.EncryptUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class MessageService {

    @Autowired
    private SmsService smsService;
    @Autowired
    private VerifyCodeService verifyCodeService;


    @Transactional
    public void sendCode(String phone) {
        String randomCode = EncryptUtil.randomNum();
        Map<String, String> map = new HashMap<>();
        map.put("code", randomCode);
        smsService.sendMessage(phone, "SMS_123736576", map);
        verifyCodeService.createVerifyCode(phone, randomCode);
    }

    public void sendApplyMessage(String name) {
        Map<String, String> map = new HashMap<>();
        map.put("name", name);
        smsService.sendMessage("18531126198", "SMS_164266875", map);
    }


}
